//
//  SISSRecommendPriceViewController.m
//  SISSAPP
//
//  Created by 袁应荣 on 2018/9/10.
//  Copyright © 2018年 优房网. All rights reserved.
//

#import "SISSRecommendPriceViewController.h"
#import "SISSSaleRentPriceOnImageView.h"
#import "SISSSellRentNumPriceView.h"
#import "SISSPriceTrendChart.h"
#import "SISSHousesBasicInfoView.h"
#import "SISSJsonRequestNetworkingManager+Registration.h"
#import "SISSJsonRequestNetworkingManager+Map.h"

@interface SISSRecommendPriceViewController ()


@property (weak, nonatomic) SISSSaleRentPriceOnImageView *saleRentPriceOnImageView;

@property (weak, nonatomic) SISSSellRentNumPriceView *numPriceView;
@property (weak, nonatomic) SISSPriceTrendChart *priceTrendChart;
@property (weak, nonatomic) SISSHousesBasicInfoView *houseInfoView;
@property (weak, nonatomic) UIButton *recommendButton;

/// model
@property (strong, nonatomic) SISSHouseEstateHomePageInfoModel *houseEstateHomePageInfo;

@end

@implementation SISSRecommendPriceViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    if (@available(iOS 11.0, *)) {
        self.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    

}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    // 把背景设为空
    [self.navigationController.navigationBar setBackgroundImage:[ImageWithColor imageWithColor:[UIColor clearColor]] forBarMetrics:UIBarMetricsDefault];
    // 处理导航栏有条线的问题
    [self.navigationController.navigationBar setShadowImage:[UIImage new]];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.navigationController.navigationBar setBackgroundImage:[ImageWithColor imageWithColor:[UIColor colorWithWhite:1 alpha:0.99]] forBarMetrics:UIBarMetricsDefault];
}


- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    // 禁止下拉
    if (scrollView.contentOffset.y <= 0) {
        scrollView.contentOffset = CGPointMake(0, 0);
    }
    
    CGFloat alpha = scrollView.contentOffset.y / kTopHeight;
    [self.navigationController.navigationBar setBackgroundImage:[ImageWithColor imageWithColor:[UIColor colorWithWhite:1 alpha:alpha]] forBarMetrics:UIBarMetricsDefault];
}

- (void)setIsMapIn:(BOOL)isMapIn {
    _isMapIn = isMapIn;
    self.recommendButton.hidden = isMapIn;
}

- (void)setCommunityName:(NSString *)communityName {
    _communityName = communityName;
    [kJsonRequestNetworkingManager requestHouseEstateHomePageInfoWithCommunityName:communityName successBlock:^(SISSHouseEstateHomePageInfoModel *houseEstateHomePageInfoModel) {
        self.houseEstateHomePageInfo = houseEstateHomePageInfoModel;
    } failed:^(NSError *error) {
        NSLog(@"%@",error);
    }];
}

- (void)setTownNo:(NSString *)townNo {
    _townNo = townNo;
    self.houseInfoView.hidden = YES;
    [kJsonRequestNetworkingManager requestTownEvaluationDetailWithTownNo:townNo successBlock:^(SISSHouseEstateHomePageInfoModel *townDetailInfoModel) {
        self.houseEstateHomePageInfo = townDetailInfoModel;
    } failed:^(NSError *error) {
        NSLog(@"%@",error);
    }];
}

- (void)setBlockNo:(NSString *)blockNo {
    _blockNo = blockNo;
    self.houseInfoView.hidden = YES;
    
    [kJsonRequestNetworkingManager requestBlockEvaluationDetailWithBlockNo:blockNo successBlock:^(SISSHouseEstateHomePageInfoModel *blockDetailInfoModel) {
        self.houseEstateHomePageInfo = blockDetailInfoModel;
    } failed:^(NSError *error) {
        NSLog(@"%@",error);
    }];
}

- (void)setHouseEstateHomePageInfo:(SISSHouseEstateHomePageInfoModel *)houseEstateHomePageInfo {
    _houseEstateHomePageInfo = houseEstateHomePageInfo;
    
    self.saleRentPriceOnImageView.pagePic = houseEstateHomePageInfo.pagePic;
    self.saleRentPriceOnImageView.communityName = houseEstateHomePageInfo.pname;
    self.saleRentPriceOnImageView.averageSellPrice = houseEstateHomePageInfo.averageSell;
    self.saleRentPriceOnImageView.averageRentPrice = houseEstateHomePageInfo.averageRent;
    self.saleRentPriceOnImageView.pageDescription = houseEstateHomePageInfo.pageDescription;
    
    NSString *sellNum = houseEstateHomePageInfo.sellHouseRelevant.houseCount.floatValue > 0 ? houseEstateHomePageInfo.sellHouseRelevant.houseCount : @"--";
    NSString *sellPrice = houseEstateHomePageInfo.sellHouseRelevant.averagePrice;
    NSString *sellAvgPrice = (sellPrice.length > 0 && sellPrice.floatValue > 0) ? [NSString stringWithFormat:@"%.2f",sellPrice.floatValue] : @"--";
    NSString *rentNum = houseEstateHomePageInfo.rentHouseRelevant.houseCount.length > 0 ? houseEstateHomePageInfo.rentHouseRelevant.houseCount : @"--";
    NSString *rentPrice = houseEstateHomePageInfo.rentHouseRelevant.averagePrice;
    NSString *rentAvgPrice = (rentPrice.length > 0 && rentPrice.floatValue > 0) ? [NSString stringWithFormat:@"%.2f",rentPrice.floatValue] : @"--";
    
    /// &&$$ 为方便值传过好切分给Label字体分段颜色
    self.numPriceView.sellNumAvgPrice = [NSString stringWithFormat:@"%@&&$$%@",sellNum,sellAvgPrice];
    self.numPriceView.rentNumAvgPrice = [NSString stringWithFormat:@"%@&&$$%@",rentNum,rentAvgPrice];
    
    self.priceTrendChart.priceChartModel = houseEstateHomePageInfo.priceChart;
    
    /// 展示区域和板块时没有相应数据
    if (self.communityName.length > 0) {
       self.houseInfoView.buildInfo = houseEstateHomePageInfo.buildInfo;
    }
}

#pragma mark - 推荐售价点击事件
- (void)recommendButtonClickAction {
    if (self.recommendPriceBlock) {
        if (self.isRentOut) {
            NSRange range = [self.houseEstateHomePageInfo.averageRent rangeOfString:@"元/月/㎡"]; // 匹配得到的下标
            NSString *avgPrice =self.houseEstateHomePageInfo.averageRent.length > 0 ? [self.houseEstateHomePageInfo.averageRent substringWithRange:NSMakeRange(0,range.location)] : @"";
            self.recommendPriceBlock(avgPrice);
        } else {
            NSRange range1 = [self.houseEstateHomePageInfo.averageSell rangeOfString:@":"]; // 匹配得到的下标
            NSRange range2 = [self.houseEstateHomePageInfo.averageSell rangeOfString:@"元/㎡"]; // 匹配得到的下标
            NSString *avgPrice = self.houseEstateHomePageInfo.averageSell.length > 0 ? [self.houseEstateHomePageInfo.averageSell substringWithRange:NSMakeRange(range1.location + range1.length, range2.location - range1.location - range1.length)] : @"";
            self.recommendPriceBlock(avgPrice);
        }
        
    }
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark - UI
- (void)setupSubviews {
    [super setupSubviews];
    
    SISSSaleRentPriceOnImageView *saleRentPriceOnImageView = [[SISSSaleRentPriceOnImageView alloc] init];
    [self.containerView addSubview:saleRentPriceOnImageView];
    self.saleRentPriceOnImageView = saleRentPriceOnImageView;
    
    SISSSellRentNumPriceView *numPriceView = [[SISSSellRentNumPriceView alloc] init];
    [self.containerView addSubview:numPriceView];
    self.numPriceView = numPriceView;
    
    SISSPriceTrendChart *priceTrendChart = [[SISSPriceTrendChart alloc] init];
    [self.containerView addSubview:priceTrendChart];
    self.priceTrendChart = priceTrendChart;
    
    SISSHousesBasicInfoView *houseInfoView = [[SISSHousesBasicInfoView alloc] init];
    [self.containerView addSubview:houseInfoView];
    self.houseInfoView = houseInfoView;
    if (self.isMapIn && (self.townNo.length > 0 || self.blockNo.length > 0)) {
        self.houseInfoView.hidden = YES;
    }
    
    UIButton *recommendButton = [UIButton buttonWithType:UIButtonTypeCustom];
    NSString *title = self.isRentOut ? @"使用推荐租金" : @"使用推荐售价";
    [recommendButton setTitle:title forState:UIControlStateNormal];
    recommendButton.titleLabel.font = [UIFont systemFontOfSize:15];
    [recommendButton setBackgroundColor:MAIN_COLOR];
    [recommendButton addTarget:self action:@selector(recommendButtonClickAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:recommendButton];
    self.recommendButton = recommendButton;
    self.recommendButton.hidden = self.isMapIn;

}

#pragma mark - 约束
- (void)initConstraint {
    [super initConstraint];
    
    WeakSelf
    CGFloat margin = 8.0;
    [self.scrollView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.mas_topLayoutGuideBottom).offset(-kTopHeight);
    }];
    
    [self.saleRentPriceOnImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.containerView);
        make.left.right.equalTo(weakSelf.containerView);
        make.height.mas_equalTo(250);
    }];
    
    [self.numPriceView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.saleRentPriceOnImageView.mas_bottom);
        make.left.right.equalTo(weakSelf.containerView);
    }];
    
    if (self.isMapIn && (self.townNo.length > 0 || self.blockNo.length > 0)) {
        [self.priceTrendChart mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakSelf.numPriceView.mas_bottom);
            make.left.right.equalTo(weakSelf.containerView);
            make.bottom.equalTo(weakSelf.containerView).offset(-6 *margin);
        }];
    } else {
        [self.priceTrendChart mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakSelf.numPriceView.mas_bottom);
            make.left.right.equalTo(weakSelf.containerView);
        }];
        [self.houseInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakSelf.priceTrendChart.mas_bottom);
            make.left.right.equalTo(weakSelf.containerView);
            make.bottom.equalTo(weakSelf.containerView).offset(-7 *margin);
        }];
    }
    
     [self.recommendButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(weakSelf.view);
        make.height.mas_equalTo(5.5 * margin);
        if (@available(iOS 11.0, *)) {
            make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom);
        } else {
            make.bottom.equalTo(weakSelf.view);
        }
    }];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//#import "SISSRecommendPriceViewController.h"
//#import "SISSSaleRentPriceOnImageView.h"
//#import "SISSSellRentNumPriceView.h"
//#import "SISSPriceTrendChart.h"
//#import "SISSHousesBasicInfoView.h"
//#import "SISSJsonRequestNetworkingManager+Registration.h"
//#import "SISSJsonRequestNetworkingManager+Map.h"
//#import "SISSTitleView.h"
//#import "SISSHouseAveragePriceCell.h"
//
//@interface SISSRecommendPriceViewController ()<UITableViewDelegate,UITableViewDataSource,SSISSHouseAveragePriceCellDelegate>
//
//
//@property (weak, nonatomic) SISSSaleRentPriceOnImageView *saleRentPriceOnImageView;
//
//@property (weak, nonatomic) SISSTitleView *titleView;
//@property (weak, nonatomic) UITableView *tableView;
//
////@property (weak, nonatomic) SISSSellRentNumPriceView *numPriceView;
//@property (weak, nonatomic) SISSPriceTrendChart *priceTrendChart;
//@property (weak, nonatomic) SISSHousesBasicInfoView *houseInfoView;
//@property (weak, nonatomic) UIButton *recommendButton;
//
///// model
//@property (strong, nonatomic) SISSHouseEstateHomePageInfoModel *houseEstateHomePageInfo;
//
/////
//@property (strong, nonatomic) NSMutableArray<SISSHouseAveragePriceModel *> *dataArrM;
//
//@end
//
//@implementation SISSRecommendPriceViewController
//
//- (void)viewDidLoad {
//    [super viewDidLoad];
//    // Do any additional setup after loading the view.
//
//    if (@available(iOS 11.0, *)) {
//        self.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
//    } else {
//        self.automaticallyAdjustsScrollViewInsets = NO;
//    }
//
//
//}
//
//- (void)viewWillAppear:(BOOL)animated {
//    [super viewWillAppear:animated];
//
//    // 把背景设为空
//    [self.navigationController.navigationBar setBackgroundImage:[ImageWithColor imageWithColor:[UIColor clearColor]] forBarMetrics:UIBarMetricsDefault];
//    // 处理导航栏有条线的问题
//    [self.navigationController.navigationBar setShadowImage:[UIImage new]];
//}
//
//- (void)viewWillDisappear:(BOOL)animated {
//    [super viewWillDisappear:animated];
//    [self.navigationController.navigationBar setBackgroundImage:[ImageWithColor imageWithColor:[UIColor colorWithWhite:1 alpha:0.99]] forBarMetrics:UIBarMetricsDefault];
//}
//
//
//- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
//    // 禁止下拉
//    if (scrollView.contentOffset.y <= 0) {
//        scrollView.contentOffset = CGPointMake(0, 0);
//    }
//
//    CGFloat alpha = scrollView.contentOffset.y / kTopHeight;
//    [self.navigationController.navigationBar setBackgroundImage:[ImageWithColor imageWithColor:[UIColor colorWithWhite:1 alpha:alpha]] forBarMetrics:UIBarMetricsDefault];
//}
//
//- (void)setIsMapIn:(BOOL)isMapIn {
//    _isMapIn = isMapIn;
//    self.recommendButton.hidden = isMapIn;
//}
//
//- (void)setCommunityName:(NSString *)communityName {
//    _communityName = communityName;
//    WeakSelf
//    [kJsonRequestNetworkingManager requestHouseEstateHomePageInfoWithCommunityName:communityName successBlock:^(SISSHouseEstateHomePageInfoModel *houseEstateHomePageInfoModel) {
//        weakSelf.houseEstateHomePageInfo = houseEstateHomePageInfoModel;
//
//    } failed:^(NSError *error) {
//        NSLog(@"%@",error);
//    }];
//}
//
//- (void)setTownNo:(NSString *)townNo {
//    _townNo = townNo;
//    self.houseInfoView.hidden = YES;
//
//    [kJsonRequestNetworkingManager requestTownEvaluationDetailWithTownNo:townNo successBlock:^(SISSHouseEstateHomePageInfoModel *townDetailInfoModel) {
//        self.houseEstateHomePageInfo = townDetailInfoModel;
//
//    } failed:^(NSError *error) {
//        NSLog(@"%@",error);
//    }];
//}
//
//- (void)setBlockNo:(NSString *)blockNo {
//    _blockNo = blockNo;
//    self.houseInfoView.hidden = YES;
//
//    [kJsonRequestNetworkingManager requestBlockEvaluationDetailWithBlockNo:blockNo successBlock:^(SISSHouseEstateHomePageInfoModel *blockDetailInfoModel) {
//        self.houseEstateHomePageInfo = blockDetailInfoModel;
//    } failed:^(NSError *error) {
//        NSLog(@"%@",error);
//    }];
//}
//
//- (void)setHouseEstateHomePageInfo:(SISSHouseEstateHomePageInfoModel *)houseEstateHomePageInfo {
//    _houseEstateHomePageInfo = houseEstateHomePageInfo;
//
//    self.saleRentPriceOnImageView.pagePic = houseEstateHomePageInfo.pagePic;
//    self.saleRentPriceOnImageView.communityName = houseEstateHomePageInfo.pname;
//    self.saleRentPriceOnImageView.averageSellPrice = houseEstateHomePageInfo.averageSell;
//    self.saleRentPriceOnImageView.averageRentPrice = houseEstateHomePageInfo.averageRent;
//    self.saleRentPriceOnImageView.pageDescription = houseEstateHomePageInfo.pageDescription;
//
////    NSString *sellNum = houseEstateHomePageInfo.sellHouseRelevant.houseCount.floatValue > 0 ? houseEstateHomePageInfo.sellHouseRelevant.houseCount : @"--";
////    NSString *sellPrice = houseEstateHomePageInfo.sellHouseRelevant.averagePrice;
////    NSString *sellAvgPrice = (sellPrice.length > 0 && sellPrice.floatValue > 0) ? [NSString stringWithFormat:@"%.2f",sellPrice.floatValue] : @"--";
////    NSString *rentNum = houseEstateHomePageInfo.rentHouseRelevant.houseCount.length > 0 ? houseEstateHomePageInfo.rentHouseRelevant.houseCount : @"--";
////    NSString *rentPrice = houseEstateHomePageInfo.rentHouseRelevant.averagePrice;
////    NSString *rentAvgPrice = (rentPrice.length > 0 && rentPrice.floatValue > 0) ? [NSString stringWithFormat:@"%.2f",rentPrice.floatValue] : @"--";
//
//    /// &&$$ 为方便值传过好切分给Label字体分段颜色
////    self.numPriceView.sellNumAvgPrice = [NSString stringWithFormat:@"%@&&$$%@",sellNum,sellAvgPrice];
////    self.numPriceView.rentNumAvgPrice = [NSString stringWithFormat:@"%@&&$$%@",rentNum,rentAvgPrice];
//
//    if (houseEstateHomePageInfo.averageSell.length > 0) {
//        SISSHouseAveragePriceModel *model = [[SISSHouseAveragePriceModel alloc] init];
//        model.leftTitle = @"房谱网";
//        model.middlePrice = houseEstateHomePageInfo.averageSell;
//        model.rightButtonStr = @"使用均价";
//        [self.dataArrM addObject:model];
//    }
//    if (houseEstateHomePageInfo.lianjiaPrice.length > 0) {
//        SISSHouseAveragePriceModel *model = [[SISSHouseAveragePriceModel alloc] init];
//        model.leftTitle = @"链家网";
//        model.middlePrice = houseEstateHomePageInfo.lianjiaPrice;
//        model.rightButtonStr = @"使用均价";
//        [self.dataArrM addObject:model];
//    }
//    if (houseEstateHomePageInfo.qfangPrice.length > 0) {
//        SISSHouseAveragePriceModel *model = [[SISSHouseAveragePriceModel alloc] init];
//        model.leftTitle = @"Q房网";
//        model.middlePrice = houseEstateHomePageInfo.qfangPrice;
//        model.rightButtonStr = @"使用均价";
//        [self.dataArrM addObject:model];
//    }
//    if (houseEstateHomePageInfo.lengyoujiaPrice.length > 0) {
//        SISSHouseAveragePriceModel *model = [[SISSHouseAveragePriceModel alloc] init];
//        model.leftTitle = @"乐有家";
//        NSRegularExpression *regular = [NSRegularExpression regularExpressionWithPattern:@"[^0-9]" options:0 error:NULL];
//        houseEstateHomePageInfo.lengyoujiaPrice = [regular stringByReplacingMatchesInString:houseEstateHomePageInfo.lengyoujiaPrice options:0 range:NSMakeRange(0, [houseEstateHomePageInfo.lengyoujiaPrice length]) withTemplate:@""];
//        model.middlePrice = houseEstateHomePageInfo.lengyoujiaPrice;
//        model.rightButtonStr = @"使用均价";
//        [self.dataArrM addObject:model];
//    }
//    if (houseEstateHomePageInfo.fangtianxiaPrice.length > 0) {
//        SISSHouseAveragePriceModel *model = [[SISSHouseAveragePriceModel alloc] init];
//        model.leftTitle = @"房天下";
//        model.middlePrice = houseEstateHomePageInfo.fangtianxiaPrice;
//        model.rightButtonStr = @"使用均价";
//        [self.dataArrM addObject:model];
//    }
//    if (houseEstateHomePageInfo.tongchengPrice.length > 0) {
//        SISSHouseAveragePriceModel *model = [[SISSHouseAveragePriceModel alloc] init];
//        model.leftTitle = @"58同城";
//        model.middlePrice = houseEstateHomePageInfo.tongchengPrice;
//        model.rightButtonStr = @"使用均价";
//        [self.dataArrM addObject:model];
//    }
//    if (houseEstateHomePageInfo.zhengfuPrice.length > 0) {
//        SISSHouseAveragePriceModel *model = [[SISSHouseAveragePriceModel alloc] init];
//        model.leftTitle = @"政府评估";
//        model.middlePrice = houseEstateHomePageInfo.zhengfuPrice;
//        model.rightButtonStr = @"显示均价";
//        [self.dataArrM addObject:model];
//    }
//    WeakSelf
//    [self.tableView mas_updateConstraints:^(MASConstraintMaker *make) {
//        make.height.mas_equalTo(weakSelf.dataArrM.count * 69);
//    }];
//    [self.tableView reloadData];
//
//    self.priceTrendChart.priceChartModel = houseEstateHomePageInfo.priceChart;
//
//    /// 展示区域和板块时没有相应数据
//    if (self.communityName.length > 0) {
//       self.houseInfoView.buildInfo = houseEstateHomePageInfo.buildInfo;
//    }
//}
//
//#pragma mark - UITableViewDelegate & UITableViewDataSource
//
//- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
//    return self.dataArrM.count;
//}
//
//- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//
//    SISSHouseAveragePriceCell *cell = [tableView dequeueReusableCellWithIdentifier:houseAveragePriceCellReuseID forIndexPath:indexPath];
//    cell.delegate = self;
//    cell.model = self.dataArrM[indexPath.row];
//    return cell;
//}
//
//#pragma mark -- SSISSHouseAveragePriceCellDelegate
//- (void)clickRecommendPriceButtonWithCell:(SISSHouseAveragePriceCell *)cell {
//
//    NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
//    SISSHouseAveragePriceModel *model = self.dataArrM[indexPath.row];
//    if (indexPath.row == self.dataArrM.count - 1 && [self.dataArrM.lastObject.leftTitle isEqualToString:@"政府评估"]) {
//        if ([self.dataArrM.lastObject.middlePrice isEqualToString:@"?"]) {
//            self.dataArrM.lastObject.middlePrice = self.houseEstateHomePageInfo.tongchengPrice;
//            self.dataArrM.lastObject.rightButtonStr = @"隐藏均价";
//        } else {
//            self.dataArrM.lastObject.middlePrice = @"?";
//            self.dataArrM.lastObject.rightButtonStr = @"显示均价";
//        }
//        [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
//    } else {
//        if (self.recommendPriceBlock) {
//            if (self.isRentOut) {
//
//            } else {
//                self.recommendPriceBlock(model.middlePrice);
//            }
//            [self.navigationController popViewControllerAnimated:YES];
//        }
//    }
//    NSLog(@"%@",indexPath);
//}
//
//#pragma mark - 推荐售价点击事件
////- (void)recommendButtonClickAction {
////    if (self.recommendPriceBlock) {
////        if (self.isRentOut) {
////            NSRange range = [self.houseEstateHomePageInfo.averageRent rangeOfString:@"元/月/㎡"]; // 匹配得到的下标
////            NSString *avgPrice =self.houseEstateHomePageInfo.averageRent.length > 0 ? [self.houseEstateHomePageInfo.averageRent substringWithRange:NSMakeRange(0,range.location)] : @"";
////            self.recommendPriceBlock(avgPrice);
////        } else {
////            NSRange range1 = [self.houseEstateHomePageInfo.averageSell rangeOfString:@":"]; // 匹配得到的下标
////            NSRange range2 = [self.houseEstateHomePageInfo.averageSell rangeOfString:@"元/㎡"]; // 匹配得到的下标
////            NSString *avgPrice = self.houseEstateHomePageInfo.averageSell.length > 0 ? [self.houseEstateHomePageInfo.averageSell substringWithRange:NSMakeRange(range1.location + range1.length, range2.location - range1.location - range1.length)] : @"";
////            self.recommendPriceBlock(avgPrice);
////        }
////
////    }
////    [self.navigationController popViewControllerAnimated:YES];
////}
//
//#pragma mark - UI
//- (void)setupSubviews {
//    [super setupSubviews];
//
//    SISSSaleRentPriceOnImageView *saleRentPriceOnImageView = [[SISSSaleRentPriceOnImageView alloc] init];
//    [self.containerView addSubview:saleRentPriceOnImageView];
//    self.saleRentPriceOnImageView = saleRentPriceOnImageView;
//
//    SISSTitleView *titleView = [[SISSTitleView alloc] init];
//    titleView.titleStr = @"各机构二手房平均售价";
//    titleView.titleColor = MAIN_TEXT_COLOR;
//    [self.containerView addSubview:titleView];
//    self.titleView = titleView;
//
//    SISSBaseTableView *tableView = [[SISSBaseTableView alloc] init];
//    tableView.estimatedRowHeight = 44;
//    tableView.rowHeight = UITableViewAutomaticDimension;
//    tableView.delegate = self;
//    tableView.dataSource = self;
//    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
//    tableView.scrollEnabled = NO;
//    [tableView registerClass:[SISSHouseAveragePriceCell class] forCellReuseIdentifier:houseAveragePriceCellReuseID];
//    [self.containerView addSubview:tableView];
//    self.tableView = tableView;
//
////    SISSSellRentNumPriceView *numPriceView = [[SISSSellRentNumPriceView alloc] init];
////    [self.containerView addSubview:numPriceView];
////    self.numPriceView = numPriceView;
//
//    SISSPriceTrendChart *priceTrendChart = [[SISSPriceTrendChart alloc] init];
//    [self.containerView addSubview:priceTrendChart];
//    self.priceTrendChart = priceTrendChart;
//
//    SISSHousesBasicInfoView *houseInfoView = [[SISSHousesBasicInfoView alloc] init];
//    [self.containerView addSubview:houseInfoView];
//    self.houseInfoView = houseInfoView;
//    if (self.isMapIn && (self.townNo.length > 0 || self.blockNo.length > 0)) {
//        self.houseInfoView.hidden = YES;
//    }
//
////    UIButton *recommendButton = [UIButton buttonWithType:UIButtonTypeCustom];
////    NSString *title = self.isRentOut ? @"使用推荐租金" : @"使用推荐售价";
////    [recommendButton setTitle:title forState:UIControlStateNormal];
////    recommendButton.titleLabel.font = [UIFont systemFontOfSize:15];
////    [recommendButton setBackgroundColor:MAIN_COLOR];
////    [recommendButton addTarget:self action:@selector(recommendButtonClickAction) forControlEvents:UIControlEventTouchUpInside];
////    [self.view addSubview:recommendButton];
////    self.recommendButton = recommendButton;
////    self.recommendButton.hidden = self.isMapIn;
//
//}
//
//#pragma mark - 约束
//- (void)initConstraint {
//    [super initConstraint];
//
//    WeakSelf
//    CGFloat margin = 8.0;
//    [self.scrollView mas_updateConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(weakSelf.mas_topLayoutGuideBottom).offset(-kTopHeight);
//    }];
//
//    [self.saleRentPriceOnImageView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(weakSelf.containerView);
//        make.left.right.equalTo(weakSelf.containerView);
//        make.height.mas_equalTo(250);
//    }];
//
////    [self.numPriceView mas_makeConstraints:^(MASConstraintMaker *make) {
////        make.top.equalTo(weakSelf.saleRentPriceOnImageView.mas_bottom);
////        make.left.right.equalTo(weakSelf.containerView);
////    }];
//    [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(weakSelf.saleRentPriceOnImageView.mas_bottom);
//        make.left.right.equalTo(weakSelf.containerView);
//        make.height.mas_equalTo(margin * margin);
//    }];
//    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(weakSelf.titleView.mas_bottom);
//        make.left.right.equalTo(weakSelf.containerView);
//        make.height.mas_equalTo(88);
//    }];
//
//    if (self.isMapIn && (self.townNo.length > 0 || self.blockNo.length > 0)) {
//        [self.priceTrendChart mas_makeConstraints:^(MASConstraintMaker *make) {
////            make.top.equalTo(weakSelf.numPriceView.mas_bottom);
//            make.top.equalTo(weakSelf.tableView.mas_bottom);
//            make.left.right.equalTo(weakSelf.containerView);
//            make.bottom.equalTo(weakSelf.containerView).offset(-6 *margin);
//        }];
//    } else {
//        [self.priceTrendChart mas_makeConstraints:^(MASConstraintMaker *make) {
////            make.top.equalTo(weakSelf.numPriceView.mas_bottom);
//            make.top.equalTo(weakSelf.tableView.mas_bottom);
//            make.left.right.equalTo(weakSelf.containerView);
//        }];
//        [self.houseInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.equalTo(weakSelf.priceTrendChart.mas_bottom);
//            make.left.right.equalTo(weakSelf.containerView);
//            make.bottom.equalTo(weakSelf.containerView).offset(-7 *margin);
//        }];
//    }
//
////     [self.recommendButton mas_makeConstraints:^(MASConstraintMaker *make) {
////        make.left.right.equalTo(weakSelf.view);
////        make.height.mas_equalTo(5.5 * margin);
////        if (@available(iOS 11.0, *)) {
////            make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom);
////        } else {
////            make.bottom.equalTo(weakSelf.view);
////        }
////    }];
//}
//
//- (NSMutableArray *)dataArrM {
//    if (!_dataArrM) {
//        _dataArrM = [NSMutableArray array];
//    }
//    return _dataArrM;
//}
//
//- (void)didReceiveMemoryWarning {
//    [super didReceiveMemoryWarning];
//    // Dispose of any resources that can be recreated.
//}



@end
